Pulse width modulation technique with time-ratio duty cycle computation

ABSTRACT

An analog signal-to-pulse width modulation (PWM) converter includes a ramp generator generating a ramp signal and a comparator circuit comparing the ramp signal to a first voltage, a second voltage, and an analog input signal. A duty cycle calculation circuit generates a first control signal to the ramp generator to generate the ramp signal. Based on signals from the comparator circuit, the duty cycle calculation circuit calculates the ratio of the time it takes for the ramp signal to exceed the analog input signal from when the ramp signal exceeds the first voltage to the time it takes for the ramp signal to exceed the second voltage from when the ramp signal exceeds the first voltage. A PWM signal generator generates a PWM output signal based on the ratio calculated by the duty cycle calculation circuit.

BACKGROUND

In some applications, an analog signal is converted into a pulse width modulation (PWM) output signal. For example, some sensors, generate an analog output signal representative of a physical condition, and the sensor's analog output signal is converted into a PWM output signal that encodes the analog output signal.

SUMMARY

In one embodiment, an analog signal-to-PWM converter includes a ramp generator to generate a ramp signal and a comparator circuit to compare the ramp signal to a first voltage, a second voltage, and to an analog input signal. A duty cycle calculation circuit generates a first control signal to the ramp generator to cause the ramp generator circuit to generate the ramp signal. Based on signals from the comparator circuit, the duty cycle calculation circuit calculates the ratio of the time it takes for the ramp signal to exceed the analog input signal from when the ramp signal exceeds the first voltage to the time it takes for the ramp signal to exceed the second voltage from when the ramp signal exceeds the first voltage. A PWM signal generator generates a PWM output signal based, at least in part, on the ratio calculated by the duty cycle calculation circuit.

In another embodiment, an analog signal-to-PWM converter includes a ramp generator configured to generate a ramp signal, a comparator circuit configured to compare the ramp signal to a first voltage, a second voltage, and to an analog input signal and a digital core coupled to the comparator circuit. The digital core is configured to generate a first control signal to the ramp generator to cause the ramp generator circuit to generate the ramp signal. Based on signals from the comparator circuit, the digital core is configured to calculate a ratio of the time it takes for the ramp signal to exceed the analog input signal from when the ramp signal exceeds the first voltage to the time it takes for the ramp signal to exceed the second voltage from when the ramp signal exceeds the first voltage. The digital core also is configured to generate a PWM output signal based, at least in part, on the ratio.

In another embodiment, a method includes generating a ramp signal, comparing the ramp signal to a first voltage to generate a first compare signal, comparing the ramp signal to a second voltage to generate a second compare signal, and comparing the ramp signal to an analog input signal to generate a third compare signal. Based on the first, second and third compare signals, the method includes calculating a ratio of the time it takes for the ramp signal to exceed the analog input signal from when the ramp signal exceeds the first voltage to the time it takes for the ramp signal to exceed the second voltage from when the ramp signal exceeds the first voltage. The method further includes generating a PWM output signal based, at least in part, on the ratio.

BRIEF DESCRIPTION OF THE DRAWINGS

For a detailed description of various examples, reference will now be made to the accompanying drawings in which:

FIG. 1 illustrates an example of an analog-to-PWM converter including a signal selection circuit, a pair of comparators and a digital core.

FIG. 2 provides a duty cycle calculation circuit of the illustrative digital core of FIG. 1.

FIG. 3 is a timing diagram of the operation of the analog-to-PWM converter in accordance with an embodiment.

FIG. 4 provides a PWM signal generator of the illustrative digital core of FIG. 1.

FIG. 5 illustrates another example of an analog-to-PWM converter including a signal selection circuit, a single comparator, and a digital core.

FIG. 6 is a timing diagram of the operation of the analog-to-PWM converter of FIG. 5 in accordance with an embodiment.

FIG. 7 is a duty cycle calculation circuit usable in the digital core of the example of FIG. 5.

FIG. 8 illustrates yet another example of an analog-to-PWM converter including multiple comparators and a digital core with no signal selection circuit.

FIG. 9 is a timing diagram of the operation of the analog-to-PWM converter of FIG. 8 in accordance with an embodiment.

FIG. 10 is a duty cycle calculation circuit usable in the digital core of the example FIG. 8.

FIG. 11 is an example of a method for converting an analog input signal into a PWM output signal in accordance with the disclosed embodiments.

DETAILED DESCRIPTION

FIG. 1 is a block diagram of an analog signal-to-PWM converter 100 in accordance with an embodiment. In the example of FIG. 1, the analog signal-to-PWM converter 100 includes an analog circuit 102 a coupled to a digital core 200 a. The analog circuit 102 a receives an analog input signal Vsig and the digital core 200 a generates a corresponding PWM output signal. The magnitude of Vsig is encoded in the duty cycle of the PWM output signal.

The analog circuit 102 a of the example of FIG. 1 includes a signal selection circuit 110 a, comparator circuit 120 a, and a ramp generator 130. The digital core 200 a includes a duty cycle calculator circuit 210 a coupled to a PWM signal generator 220. The ramp generator 130 within the analog circuit 102 a includes a capacitor C1, a current source 11, and switches 132 and 134. A control signal CHARGE_CAP generated by the digital core 200 a (e.g., generated by the duty cycle calculation circuit 210 a within the digital core 200 a) controls the switches 132 and 134. The ramp generator 130 generates a ramp signal (RAMP), which is a voltage that increases generally linearly when switch 132 is closed and switch 134 thereby permitting current from the current source 11 to charge the capacitor C1. The ramp signal then decreases generally linearly when switch 132 is open and switch 134 is closed thereby providing a current path to ground for the capacitor C1 to discharge. The control signal CHARGE_CAP controls the states of switches 132 and 134 to cause RAMP to be generated.

The signal selection circuit 110 a in this example includes switches S1 and S2 which are configured by a control signal COMP_SEL from the duty cycle calculation circuit 210 a to select between a voltage Vmin and another voltage Vmax. In one example, COMP_SEL being at a high logic level causes switch S1 to be on and switch S2 to be off, and COMP_SEL being low turns S1 off and S2 on. The polarity can be the reverse as well in other embodiments (i.e., COMP_SEL low turns on S1 and turns off S2 while high turns S1 off and S2 on). Voltage Vmin is set to be less than or equal to Vsig, and voltage Vmax is set to be greater than or equal to Vsig. That is, Vmin≤Vsig≤Vmax. Ramp generator circuits generate a generally linear ramp signal, but the lower voltage level of the ramp signal may not be adequately linear. Vmin (and Vmax as well) is set to be in the generally linear region of the ramp signal (RAMP). The control signal COMP_SEL serially causes Vmin from the signal selection circuit 110 a to be provided to the comparator circuit 120 a for comparison to RAMP, followed by Vmax being provided to the comparator circuit 120 a.

Referring still to the example of FIG. 1, the comparator circuit 120 a includes two comparators—comparator 122 and comparator 124. The positive input of comparator 122 and the negative input of comparator 124 receive RAMP as an input signal. The negative input of comparator 122 receives the selected voltage (Vmin or Vmax) from the signal selection circuit 110 a. The positive input of comparator 124 receives Vsig. As such, comparator 122 compares RAMP to the selected Vmin or Vmax voltage from the signal selection circuit, and comparator 124 compares RAMP to Vsig. The output of comparator 122 is designated as the VREF_COMP signal and the output of comparator 124 is designated as the VSIG_COMP signal. Based on the VREF_COMP and VSIG_COMP signals from the comparator circuit 120 a, the duty cycle calculation circuit 210 a calculates a ratio of the time it takes for RAMP to exceed the analog input signal Vsig from when RAMP exceeds Vmin to the time it takes for RAMP to exceed Vmax from when RAMP exceeds Vmin.

The duty cycle calculation circuit 210 a and the PWM signal generator 220 each receive a clock signal (CLK) for use in measuring time as explained below and generating the PWM output signal. FIG. 2 shows an example of the duty cycle calculation circuit 210 a. The duty cycle calculation circuit 210 a includes a state machine 211, a T1 counter 212, a T2 counter 213, a divider 214, and a multiplier 215. The state machine 211 generates the COMP_SEL and CHARGE_CAP control signals and also generates control signals for controlling the counters 212 and 213, divider 214 and multiplier 215.

The use of the counters 212, 213 is now described with reference also to the timing diagram of FIG. 3. The signals depicted in FIG. 3 includes the CHARGE_CAP control signal which, when high in this example, causes the current source 11 to charge capacitor C1 thereby generating an upwardly increasing RAMP signal as shown at 135, and when low causes C1 to discharge resulting in a decreasing RAMP signal as shown at 136. The Vmin, Vmax, and Vsig signal levels are also shown in FIG. 3. As RAMP increases, RAMP crosses Vmin at 137, Vsig at 138, and Vmax at 139.

Upon assertion of the COMP_SEL to a logic high level in this example, switch S1 in FIG. 1 turns on (and S2 turns off) thereby providing Vmin to the negative input of comparator 122. Once RAMP exceeds Vmin, the VREF_COMP output signal from comparator 122 becomes high as shown at 141. At any point in time between RAMP exceeding Vmin and RAMP exceeding Vmax, the state machine 211 changes the logic state of COMP_SEL (depicted by falling edge 142) to thereby select Vmax to be provided to the negative input of comparator 122 for comparison to RAMP. With the higher voltage Vmax provided to the negative input of comparator 122 (and RAMP being less than Vmax), VREF_COMP transitions to a logic low level as illustrated at 143. At 138, RAMP crosses Vsig thereby causing the VSIG_COMP signal from comparator 124 to become low, as shown at 144. As RAMP continues to increase, eventually RAMP crosses Vout at 139 thereby causing VREF_COMP to again become a logic high at 145.

The time value T1 represents the time it takes for RAMP to exceed Vsig from the point in time that RAMP exceeded Vmin (i.e., the time between crossing points 137 and 138). The time value T2 represents the time it take for RAMP to exceed Vmax from the point in time that RAMP exceeded Vmin (i.e., the time between 137 and 139). The T1 and T2 counters 212 and 213 count pulses of CLK to provide values indicative of the T1 and T2 time values. Thus, the T1 counter 212 counts the number of CLK pulses between points 137 and 138, and the T2 counter 213 counts the number of CLK pulses between points 137 and 139. The state machine 211 asserts control signals to start and stop the counters. That portion of the RAMP below Vmin (which may not be sufficiently linear) is not used in these calculations and the generation of the PWM output signal. The divider 214 computes the ratio of T1 to T2. This ratio thus represents the percentage of the time that RAMP is between Vmin and Vsig to the total amount of time that RAMP is between Vmin and Vmax. The ratio T1/T2 is multiplied by the period of the PWM output signal (T_(PWM)) by multiplier 215 to produce a product T3 that is used during a subsequent cycle of the PWM output signal (e.g., there is a 1 PWM clock cycle delay between computing T3 and using it to generate the PWM output signal). T3 represents the number of pulses of a clock signal (CLK) that occurs within a time period equal to (T1/T2)*T_(PWM).

The value of T3 is used by the PWM signal generator 220 to generate the PWM output signal during the next PWM cycle having a duty cycle equal to T3/T_(PWM). FIG. 4 shows an example of the PWM signal generator 220. In this example, the PWM signal generator 220 includes a PWM counter 221, which counts pulses of CLK, coupled to a comparator 222. The output of the comparator 222 represents the PWM output signal and is a logic high (as depicted at 146 in FIG. 3) as T3 is greater than the count output by the counter 221. Once the count output from PWM counter 221 reaches T3, the output of the comparator 222 becomes a logic low as illustrated at 147 in FIG. 3. The duty cycle of the PWM cycle is T3/T_(PWM) and is equal to T1/T2.

FIG. 5 shows another embodiment of an analog-to-PWM converter 300 comprising an analog circuit 102 b coupled to a digital core 200 b. In this embodiment, the analog circuit 102 b includes a signal selection circuit 110 b, a comparator circuit 120 b, and the ramp generator 130. The ramp generator 130 may be implemented with the same or similar circuit as that shown in FIG. 1. The signal selection circuit 110 b includes three switches S3, S4, and S5. Switch S3 is coupled to Vmin. Switch S4 is coupled to Vsig and switch S5 is coupled Vmax. The switches S3-S5 are controlled by COMP_SEL from the digital core 200 b. COMP_SEL may comprise a separate control line for each of the switches.

The switches S3-S5 are used to selectively provide the Vmin, Vsig, and Vmax signals to the comparator circuit 120 b. The comparator circuit 120 b includes a single comparator 302 in this example which compares RAMP (provided to its positive input) to a selected one of the Vmin, Vsig, and Vmax voltages from the signal selection circuit 110 b provided to the comparator's negative input. The output signal from the comparator 302 is designated as VCOMP. The logic level of VCOMP indicates whether RAMP is above or below the corresponding signal on the comparator's negative input (Vmin, Vsig, or Vmax depending on the state of COMP_SEL).

FIG. 6 is a timing diagram of the signals in the embodiment of FIG. 5. The CHARGE_CAP control signal is the same as in FIG. 3 and is used to control the switches of the ramp generator 130 to generate RAMP. The Vmin, Vmax, and Vsig signals also are shown in FIG. 6 in relation to the ramp signal. Initially, all three switches S3-S5 are off. At the beginning of the ramp signal's increase, resulting from CHARGE_CAP being asserted high to charge capacitor C1, switch S3 is turned on (by operation of COMP_SEL) as shown at 310. With S3 on, Vmin is provided to comparator 302 for comparison to RAMP. VCOMP (output of the comparator) is initially low as shown but becomes high at 311 once RAMP crosses Vmin at 137. Responsive to VCOMP going high, the digital core 200 b turns off S3 and turns on S4 at 312 to thereby compare Vsig to RAMP. As a result of increasing the voltage on the comparator's negative input from Vmin to Vsig, VCOMP goes low as shown at 313. Once, however, RAMP crosses Vsig at 138, VCOMP again goes high as shown at 314.

Responsive to VCOMP going high at 314, the digital core 200 b turns off S4 and turns on S5 at 315 to thereby compare Vmax to RAMP. As a result of increasing the voltage on the comparator's negative input from Vsig to Vmax, VCOMP goes low as shown at 316. Once RAMP crosses Vmax at 139, VCOMP again becomes high as shown at 317.

T1 and T2 represent the same time periods as in FIG. 3 but are measured using consecutive pulses of a common VCOMP signal as shown. The digital core of FIG. 1 includes a duty cycle calculation circuit 210 a. FIG. 7 shows an example of an implementation of a duty cycle calculation circuit 210 b usable for the signal comparator embodiment of FIG. 5. The duty cycle calculation circuit 210 b includes a state machine 350, T1 and T2 counters 352 and 354, divider 214, multiplier 215, and switches S6 and S7. The state machine 350 sequences through the various states and asserts the COMP_SEL and CHARGE_CAP control signals as described above. The T1 and T2 counters 352, 354 count pulses of CLK to produce the values of T1 and T2 to be divided by divider 214 and then multiplied by T_(PMW) (the period of the PMW cycle) to produce T3. Switch S6 is coupled to T1 counter 352 and switch S7 is coupled to T2 counter 354. The switches S6 and S7 are controlled by control signals from the state machine 350 to selectively provide the VCOMP signal to the counters to start and stop the counters. As shown in the timing diagram of FIG. 6, T1 is the time between the first two consecutive pulses of VCOMP after RAMP begins to rise and once RAMP crosses Vmin. After RAMP crosses Vmin, the state machine asserts a control signal to turn on S4 (as described above) and to turn on S6 to start the T1 counter's counting process. Once RAMP crosses Vsig, the state machine turns off S6 to stop the TI counter.

The state machine 350 also turns on S7 upon RAMP crossing Vmin to start the T2 counter 354. The state machine continues to keep S7 in an on state until RAMP crosses Vmax at which point the state machine 350 turns off S7 to stop the T2 counter 354. The duty cycle calculation circuit 210 b is coupled to a PWM signal generator such as the PWM signal generator 220 of FIG. 4.

FIG. 8 shows another embodiment of an analog-to-PWM converter 400 comprising an analog circuit 102 c coupled to a digital core 200 c. The analog circuit 102 c includes a comparator circuit 120 c and the ramp generator 130. The comparator circuit 120 c includes three comparators 402, 404, and 406—one comparator for each of Vmax, Vsig, and Vmin. Comparator 402 compares RAMP to Vmax. Comparator 404 compares RAMP to Vsig. Comparator 406 compares RAMP to Vmin. Because a separate comparator is used for each of the signals Vmax, Vsig, and Vmin, a signal selection circuit 110 is not included in this embodiment. All three comparator output signals shown in FIG. 8 as VMAX_COMP, VSIG_COMP, and VMIN_COMP are provided to the digital core 200 c for generation of the PWM output signal.

FIG. 9 illustrates the timing diagram corresponding to the operation of the analog-to-PWM converter 400. The VMIN_COMP signal is low initially until RAMP crosses Vmin (at 137) at which time VMIN_COMP is forced high at 410 by comparator 402. Similarly, the VSIG_COMP signal is low initially until RAMP crosses Vsig (at 138) at which time VSIG_COMP is forced high at 411 by comparator 404. The VMAX_COMP signal is low initially until RAMP crosses Vmax (at 139) at which time VMAX_COMP is forced high at 412 by comparator 406.

T1 is the time period between rising edges of VMIN_COMP and VSIG_COMP and T2 is the time period between rising edges of VMIN_COMP and VMAX_COMP. FIG. 10 illustrates an embodiment of a duty cycle calculation circuit 210 c for use in the digital core 200 c. The duty cycle calculation circuit 210 c includes state machine 450, T1 and T2 counters 452, 454, divider 214, and multiplier 215. The T1 counter 452 counts pulses of CLK between the edges of VMIN_COMP and VSIG_COMP to produce the value T1, and the T2 counter 454 pulses of CLK between the edges of VMIN_COMP and VMAX_COMP to produce the value T2. The duty cycle calculation circuit 210 c is coupled to a PWM signal generator such as the PWM signal generator 220 of FIG. 4.

FIG. 11 illustrates a method of generating a PWM signal based on an analog input signal. The operations depicted in FIG. 11 can be performed in the order shown, or in a different order. Further, the operations can be performed sequentially, or two or more of the operations may be performed concurrently. The method shown can be performed using any of the embodiments described above.

At 502, the method includes generating a ramp signal. The generation of the ramp signal can be performed by coupling a constant current source through a switch to a capacitor to thereby charge the capacitor as described above. However, other circuit techniques for generating a ramp signal are possible as well.

At 504, the method includes comparing the ramp signal to a first voltage to generate a first compare signal. The first voltage comprises Vmin in some embodiments. A voltage comparator can be used to implement this operation. The method further includes at 506 comparing the ramp signal to a second voltage (e.g., Vsig) to generate a second compare signal and at 508 comparing the ramp signal to an analog input signal to generate a third compare signal (e.g., Vmax). One comparator can be used to compare the first and second voltages (Vmin and Vmax) to RAMP while another comparator compares RAMP to the analog input signal as in the example of FIG. 1. A single comparator as in the example of FIG. 5 can be used to perform all three comparisons, relying on a signal selection circuit to selectively provide the first and second voltages and the analog input signal to the comparator. Alternatively, three separate comparators can be used as in the example of FIG. 8. The first, second, and third compare signals may comprise voltages of one, two, or three different signal lines as explained in the preceding embodiments (e.g., VREF_COMP and VSIG_COMP as in FIG. 1, VCOMP as in FIG. 5, and VMIN_COMP, VSIG_COMP, and VMAX_COMP as in FIG. 8).

At 510, the method includes, based on the first, second and third compare signals, calculating a ratio of the time it takes for the ramp signal to exceed the analog input signal from when the ramp signal exceeds the first voltage to the time it takes for the ramp signal to exceed the second voltage from when the ramp signal exceeds the first voltage. In the examples above, the digital core 200 a, 200 b, 200 c calculates this ratio, such as through the use of divider 214).

Finally, at 512, the method includes generating a PWM output signal based, at least in part, on the ratio. The PWM signal generator 220 described above is usable to perform this operation.

In the embodiments discussed above, a ramp signal is generated during each PWM cycle to be used to calculate T1, T2, and T3 for determination of the duty cycle of the PWM output signal. In other embodiments, multiple ramp signals are generated during each PWM signal by the ramp generator 130. A T1 time value and a T2 time value are determined using each such ramp signal (multiple sets of counters may be used—one set for each ramp signal). The ratio of T1 to T2 is calculated for each ramp signal by the divider 214 of the corresponding digital core, and the multiple T1/T2 ratios are averaged together to produce a value of T3 to be used as described above. References to the use of the ratio of the time (T1) it takes RAMP to exceed Vsig from when RAMP exceeds Vmax to the time (T2) it takes for RAMP to exceed Vmin (i.e., the ratio T1/T2) includes a single calculation of T1/2 or an average of multiple calculations of T1/T2 generated based on multiple ramp signals.

Certain terms have been used throughout this description and claims to refer to particular system components. As one skilled in the art will appreciate, different parties may refer to a component by different names. This document does not intend to distinguish between components that differ in name but not function. In this disclosure and claims, the terms “including” and “comprising” are used in an open-ended fashion, and thus should be interpreted to mean “including, but not limited to . . . .” Also, the term “couple” or “couples” is intended to mean either an indirect or direct wired or wireless connection. Thus, if a first device couples to a second device, that connection may be through a direct connection or through an indirect connection via other devices and connections. The recitation “based on” is intended to mean “based at least in part on.” Therefore, if X is based on Y, X may be a function of Y and any number of other factors.

The above discussion is meant to be illustrative of the principles and various embodiments of the present invention. Numerous variations and modifications will become apparent to those skilled in the art once the above disclosure is fully appreciated. It is intended that the following claims be interpreted to embrace all such variations and modifications. 

What is claimed is:
 1. A converter, comprising: a ramp generator having a ramp control input, a ramp output; a first circuit having a maximum voltage input, a minimum voltage input, an analog signal input adapted to receive an analog signal, a ramp input coupled to the ramp output, and a compare output; a digital core coupled to the first circuit, in which the digital core is configured to: generate a first control signal to the ramp control input to cause the ramp generator to generate the ramp signal; based on signals from the first circuit, to determine a ratio of a first time it takes for the ramp signal to exceed the analog input signal from when the ramp signal exceeds the minimum voltage to a second time it takes for the ramp signal to exceed the maximum voltage from when the ramp signal exceeds the minimum voltage; and generate a pulse width modulation output signal on a pulse width modulation output based, at least in part, on the ratio.
 2. The converter of claim 1, in which the digital core has a selection control output; and the first circuit includes: a selection circuit having the minimum voltage input, the maximum voltage input, the analog signal input, a selection control input coupled to the selection control output, and a selection output; a first comparator having inputs coupled to the ramp input and the selection output and having a first compare output; and a second comparator having inputs coupled to the ramp input and to the analog signal input, and having a second compare output.
 3. The converter of claim 1, in which the digital core has a selection control output; and in which the first circuit includes: a selection circuit having the minimum voltage input, the maximum voltage input, the analog signal input, a selection control input coupled to the selection control output, and a selection output; and a comparator having inputs coupled to the ramp output and to the selection output.
 4. The converter of claim 1, in which the first circuit includes: a first comparator having inputs coupled to the ramp input and the minimum voltage input and having a first compare output, a second comparator having inputs coupled to the ramp input and the analog signal input and having a second compare output, and a third comparator having inputs coupled to the ramp input and the maximum voltage input and having a third compare output.
 5. The converter of claim 1, in which the digital core includes: a duty cycle circuit having a ramp control output coupled to the ramp control input, having a compare input coupled to the compare output, and having a ratio output; and a signal generator having an input coupled to the ratio output and a pulse width modulation input, and the signal generator being coupled to e the the pulse width modulation output.
 6. The converter of claim 1 in which the minimum voltage is less than a voltage of the analog signal, and the maximum voltage is greater than the voltage of the analog signal. 